package org.flint.data.structure.stack;

import org.flint.data.structure.linkedlist.LinkedList;

/**
 * @author flint92
 */
public class LinkedListStack<E> implements Stack<E> {

    private final LinkedList<E> linkedList;

    public LinkedListStack() {
        this.linkedList = new LinkedList<>();
    }


    @Override
    public void push(E e) {
        this.linkedList.addFirst(e);
    }

    @Override
    public E pop() {
        return this.linkedList.removeFirst();
    }

    @Override
    public E peek() {
        return this.linkedList.getFirst();
    }

    @Override
    public int getSize() {
        return this.linkedList.getSize();
    }

    @Override
    public boolean isEmpty() {
        return this.linkedList.isEmpty();
    }
}
